//
//  OrderIndexViewController.m
//  UniversalApp
//
//  Created by 志刚杨 on 2018/6/27.
//  Copyright © 2018年 voidcat. All rights reserved.
//

#import "OrderIndexViewController.h"
#import "CYOrderViewController.h"//排行榜

@interface OrderIndexViewController ()
{
    NSArray *list;
}
@property (nonatomic, strong) MLMSegmentHead *segHead;
@property (nonatomic, strong) MLMSegmentScroll *segScroll;
@end

@implementation OrderIndexViewController

-(void)viewDidLoad
{
    [super viewDidLoad];
    [self segmentStyle1];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}


#pragma mark - <QMUITextFieldDelegate>

- (BOOL)textFieldShouldReturn:(QMUITextField *)textField {
    
    return NO;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)segmentStyle1 {
    list = @[ASLocalizedString(@"魅力"),
             ASLocalizedString(@"财气"),
             ];
    
    UIButton *search = [[UIButton alloc] init];
    search.frame = CGRectMake(3, StatusBarHeight - 5, 50, 50);
    [search setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
    [search addTarget:self action:@selector(handleBackEvent) forControlEvents:UIControlEventTouchUpInside];
    //    search.backgroundColor = [UIColors redColor];
    [self.view addSubview:search];
    
    UIButton *order = [[UIButton alloc] init];
    order.frame = CGRectMake(SCREEN_WIDTH - 50, StatusBarHeight - 5, 50, 50);
    //    search.backgroundColor = [UIColors redColor];
    [self.view addSubview:order];
    
    
    _segHead = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(54, StatusBarHeight, SCREEN_WIDTH - 54 - 54, 40) titles:list headStyle:SegmentHeadStyleLine layoutStyle:_layout];
    //tab颜色
    _segHead.selectColor = MainColor;
    _segHead.deSelectColor = [UIColor blackColor];
    _segHead.lineColor = MainColor;
    _segHead.fontScale = 1;
    _segHead.lineHeight = 1.3;
    _segHead.fontSize = 15;
    _segHead.lineScale = .9;
    _segHead.headColor = CF6;
    _segHead.bottomLineHeight = 0;
    self.view.backgroundColor = CF6;
    _segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_segHead.frame), SCREEN_WIDTH, SCREEN_HEIGHT-CGRectGetMaxY(_segHead.frame)) vcOrViews:[self vcArr:list.count]];
    _segScroll.loadAll = NO;
    _segScroll.showIndex = 0;
    
    [MLMSegmentManager associateHead:_segHead withScroll:_segScroll completion:^{
        [self.view addSubview:_segHead];
        [self.view addSubview:_segScroll];
    }];
}

- (void)handleBackEvent {
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 数据源
- (NSArray *)vcArr:(NSInteger)count {
    NSMutableArray *arr = [NSMutableArray array];
    
    //魅力
    CYOrderViewController *order1 = [CYOrderViewController new];
    order1.isHidenNaviBar = YES;
    order1.type = @"1";
    [arr addObject:order1];
    
    //财气
    CYOrderViewController *order2 = [CYOrderViewController new];
    [arr addObject:order2];
    order2.type = @"2";

    return arr;
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //隐藏导航栏
    self.isHidenNaviBar = YES;
    self.navigationController.navigationBar.hidden = YES;
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

